package org.com.blbl.bean;



import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;


public class SubPartitionBean implements WritableComparable<SubPartitionBean>, Serializable {

    private String partition;
    private String subPartition;

    public void set(String partition, String subPartition){
        this.partition = partition;
        this.subPartition = subPartition;
    }

    public SubPartitionBean() {
    }

    public SubPartitionBean(String partition, String subPartition) {
        this.partition = partition;
        this.subPartition = subPartition;
    }

    public String getPartition() {
        return partition;
    }

    public void setPartition(String partition) {
        this.partition = partition;
    }

    public String getSubPartition() {
        return subPartition;
    }

    public void setSubPartition(String subPartition) {
        this.subPartition = subPartition;
    }

    @Override
    public String toString() {return "分区：" + partition + ", 小分区：" + subPartition;}

    @Override
    public void write(DataOutput dataOutput) throws IOException {

        dataOutput.writeUTF(partition);
        dataOutput.writeUTF(subPartition);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.partition =dataInput.readUTF();
        this.subPartition =dataInput.readUTF();
    }

    @Override
    public int compareTo(SubPartitionBean o) {
        int i = this.partition.compareTo(o.partition);
        if (i == 0){
            return this.subPartition.compareTo(o.subPartition);
        }else {
            return i;
        }
    }
}
